
import http from "@/utils/request";
import { post,get } from '@/api/request'


export const userApi = {
  login(userInfo) {
    return http({
      url: '/easuser/sys/login',
      method: 'post',
      data: userInfo
    })

  },

  getLoginUserInfo(token) {
    return http({
      url: '/easuser/user/info',
      method: 'post',
    })

  },
  updatePwd(data) {
    return http({
      url: '/easuser/user/password',
      method: 'post',
      data:data
    })

  },

  getInfo(id) {
    return http({
      url: '/easuser/user/info/'+id,
      method: 'post',
    })

  },

  saveOrUpdetaUser(data,status){
    if(status == 'save'){
      return this.saveUser(data)
    }else if(status == 'update'){
      return this.updateUser(data)
    }
  },

  logout() {
    return http({
      url: '/easuser/sys/logout',
      method: 'post'
    })
  },
  userList(data){
    return get('/easuser/user/list',data)
  },
  deleteUser(data){
    return post('/easuser/user/delete',data)
  },
  saveUser(data){
    return post('/easuser/user/save',data)
  },
  updateUser(data){
    return post('/easuser/user/update',data)
  },
  savrOrUpdateRole(data,status){
    if(status=='save'){
      return this.saveUser(data)
    }else if(status == 'update'){
      return this.updateUser(data)
    }
  },

  nav() {
    return get('/easuser/menu/nav')
  },
  menuListTree(){
    return get('/easuser/menu/listtree')
  },
  menuList(){
    return get('/easuser/menu/list')
  },
  delMenu(data=[]){
    return post('/easuser/menu/delete',data)
  },
  menuSelected(){
    return post('/easuser/menu/selected')
  },
  getMenuInfo(id = 0){
    return get('/easuser/menu/info/'+id)
  },
  seveMenu(data={}){
    return post('/easuser/menu/save',data)
  },
  updateMenu(data={}){
    return post('/easuser/menu/update',data)
  }
}

export const roleApi = {
  listRole(data){
    return get('/easuser/role/list',data)
  },
  getInfo(id){
    return get('/easuser/role/info/'+id)
  },
  deleteRole(data){
    return post('/easuser/role/deleteall',data)
  },
  saveRole(data){
    return post('/easuser/role/save',data)
  },
  updateRole(data){
    return post('/easuser/role/update',data)
  },
  savrOrUpdateRole(data,status){
    if(status=='save'){
      return this.saveRole(data)
    }else if(status == 'update'){
      return this.updateRole(data)
    }
  }
}

